#ifndef _MARIO_H_
#define _MARIO_H_
#include "GameObject.h"

#define MARIO_SPEED 6
#define SUPER_SPEED 10
#define MARIO_SPEEDWJUMP 5.5f
#define FRICTION 0.25f
#define TIME_IMMORTAL_AFTER_HIT 2
#define  TIME_SUPER_STAR 10
enum EMarioState
{
	Enone,
	Esmall,
	Ebig,
	Egun,
	Eimmortal,
	Esuperstar,
	Edie,
	Ehit,
	EResborn
};

enum EMarioAction
{
	ENone,
	EStanding,
	EStandingInBar,
	EJumping,
	ESitting,
	ERunning,
	EFalling,
	EShooting,
	EDying
};
class Mario : public GameObject
{
private:
	EMarioState marioState;
	EMarioAction marioAction;

	EMarioState nextMarioState;
	EMarioState previousState;

	CSprite* smallMario;
	CSprite* bigMario;
	CSprite* cowboyMario;

	
	float timeCheckLastPoint;
	D3DXVECTOR2 positionLastCheck;
	bool isLeft;  //Kiem tra mario dang quay ben trai hay phai
	bool hasJumped; //Kiem tra mario co dang nhay hay ko
	bool isFall; //Kiem tra mario co dang roi hay ko
	bool isStandInBar; //Kiem tra mario co dang dung tren Bar hay ko
	bool canShoot; //Kiem tra mario co duoc phep ban sung ko
	bool isImmortal; //trang thai bat tu

	bool tmpCheck; //bien tam kieu bool
	bool tmpCheck2;

	float timeShoot; 
	float timeNextShoot;
	float timeChangeState;
	float timeImmortal;
	float timeSuperStar;
	
	int alpha_immortal;
	int alpha_superstar;
	
	bool isInPiPe;

	int gold;
	int life;
	int score;
public:
	Mario(D3DXVECTOR2 pos,EMarioState stateMario, EMarioState previousState=Esmall);
	virtual ~Mario();
	void TurnLeft();
	void TurnRight();
	void Stop();
	void Jump(int v = 25);
	void Sit();
	void Fall();
	void Shoot();
	void Reborn();
	//Update & Draw method
	virtual void Update(float dt);
	virtual void UpdateCollision(list<GameObject*> , float dt);
	virtual void Draw();
	void ChangeState(float dt);
	bool isLevelFinish;
	
	int GetCoin(){return gold;}
	int GetLife(){return life;}
	int GetScore(){return score;}
	void SetCoin(int c){gold = c;}
	void SetLife(int l){life = l;}
	void SetScore(int s){score = s;}
	EMarioState GetMarioState(){return marioState;}
	EMarioState GetPreviousState(){return previousState;}
	void SetMarioState(EMarioState state){marioState = state;}

	bool GetIsInPipe(){return isInPiPe;}
};
#endif